import {
  IsBoolean,
  IsNotEmpty,
  IsOptional,
  IsString,
  Length,
} from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class CreateAddressDto {
  @ApiProperty({ description: '收货人姓名', example: '张三' })
  @IsString()
  @IsNotEmpty()
  @Length(2, 20)
  receiver: string;

  @ApiProperty({ description: '手机号', example: '13800138000' })
  @IsString()
  @IsNotEmpty()
  @Length(11, 11)
  phone: string;

  @ApiProperty({ description: '省份', example: '广东省' })
  @IsString()
  @IsNotEmpty()
  @Length(2, 50)
  province: string;

  @ApiProperty({ description: '城市', example: '深圳市' })
  @IsString()
  @IsNotEmpty()
  @Length(2, 50)
  city: string;

  @ApiProperty({ description: '区/县', example: '南山区' })
  @IsString()
  @IsNotEmpty()
  @Length(2, 50)
  district: string;

  @ApiProperty({ description: '详细地址', example: 'xx街道xx号' })
  @IsString()
  @IsNotEmpty()
  @Length(5, 100)
  detail: string;

  @ApiProperty({ description: '是否默认地址', required: false, default: false })
  @IsBoolean()
  @IsOptional()
  isDefault?: boolean = false;
}
